package org2.jogo.activities;

import org2.jogo.Global;
import org2.jogo.R;
import org2.jogo.Sound;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.TabSpec;

public class LeaderboardActivity extends TabActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.leaderboard);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.barra_titulo);
        TextView txtTitulo = (TextView) findViewById(R.id.labelTitle);
        txtTitulo.setText("Quiz Game - Leaderboard");
        Intent intent;
        for (int i = 1; i <= 3; i++) {
            intent = new Intent(this, LeaderboardTabActivity.class);
            intent.putExtra("dificuldade", i + "");
            setupTab(intent, Global.getStringDificuldade(i));
        }
        Sound.iniciaMusicaFundo(this, R.raw.music_bg_main);
    }
    
    private void setupTab(final Intent content, final String tag) {
        TabHost tabHost = getTabHost();
        View tabview = createTabView(tabHost.getContext(), tag);
        TabSpec setContent = tabHost.newTabSpec(tag).setIndicator(tabview).setContent(content);
        tabHost.addTab(setContent);
    }
    
    private static View createTabView(final Context context, final String text) {
        View view = LayoutInflater.from(context).inflate(R.layout.tab_bg, null);
        TextView tv = (TextView) view.findViewById(R.id.tabsText);
        tv.setText(text);
        return view;
    }
    
    @Override
    public void onPause() {
        super.onPause();
        Sound.pausarTodosOsSons();
    }
    
    @Override
    public void onResume() {
        super.onResume();
        Sound.continuarTodosOsSons();
    }
}
